import requests


class LogIn:
    def __init__(self, base_url):
        self.s = requests.session()
        self.base_url = base_url

    def login(self):
        # v2.5
        # wncd000-管理员
        # wncd051-邓乃文
        url = self.base_url + '/WoniuBoss2.5/log/userLogin'
        data = 'userName=wncd005&userPass=woniu123&checkcode=0000'
        headers = {'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'}
        r = self.s.post(url, data=data, headers=headers)
        if r.text == 'success':
            print('登陆成功')
        else:
            print('登陆失败')
        return self.s

    # def login(self):
    #     #2.0
    #     url = self.base_url + '/WoniuBoss2.0/log/userLogin?userName=wncd000&userPass=woniu123&checkcode=0000'
    #     r = self.s.get(url)
    #     if r.text == 'success':
    #         print('登陆成功')
    #     else:
    #         print('登陆失败')
    #     return self.s


if __name__ == '__main__':
    base_url = 'http://192.168.8.141:8080'
    login = LogIn(base_url)
    login.login()
